import { ElNotification, ElMessageBox } from 'element-plus'
import nprogress from 'nprogress'

// 封装element-plus的消息提示
export const toast = (
  title,
  message,
  type = 'success',
  duration = 1000,
  dangerouslyUseHTMLString = true
) => {
  ElNotification({
    title,
    message,
    type,
    duration,
    dangerouslyUseHTMLString //是否将 message 属性作为 HTML 片段处理
  })
}

// 封装element-plus的消息弹出框
export const dialog = (content, title, type = 'warning') => {
  return ElMessageBox.confirm(content, title, {
    confirmButtonText: '确认',
    cancelButtonText: '取消',
    type
  })
}

// 展示nprogress进度条
export const showFullLoding = () => {
  nprogress.start()
}
// 隐藏nprogress进度条
export const noshowFullLoding = () => {
  nprogress.done()
}
// 弹出输入框
export function showPrompt (tip, value = '') {
  return ElMessageBox.prompt(tip, '', {
    confirmButtonText: '确认',
    cancelButtonText: '取消',
    inputValue: value
  })
}
